*using senate_45_104_input.dta

*generate dummies for each party indicating whether party is majority (1) or minority (0) party

gen rep_status=0
replace  rep_status=1 if  congress==45
replace  rep_status=1 if  congress<53&congress>46
replace  rep_status=1 if  congress<63&congress>53
replace  rep_status=1 if  congress<73&congress>65
replace  rep_status=1 if  congress==80
replace  rep_status=1 if  congress==83
replace  rep_status=1 if  congress==97
replace  rep_status=1 if  congress==98
replace  rep_status=1 if  congress==99
replace  rep_status=1 if  congress==104

gen dem_status=0
replace  dem_status=1 if  congress==46
replace  dem_status=1 if  congress==53
replace  dem_status=1 if  congress==63
replace  dem_status=1 if  congress==64
replace  dem_status=1 if  congress==65
replace  dem_status=1 if  congress<80&congress>72
replace  dem_status=1 if  congress==81
replace  dem_status=1 if  congress==82
replace  dem_status=1 if  congress<97&congress>83
replace  dem_status=1 if  congress==100
replace  dem_status=1 if  congress==101
replace  dem_status=1 if  congress==102
replace  dem_status=1 if  congress==103

*now generate the variables indicating the position of each party: 1 for yes, 6 for no, 9 for otherwise (not identified).

gen rep_position=9
replace  rep_position=1 if  rep_yes> rep_nay
replace  rep_position=6 if  rep_nay> rep_yes

gen dem_position=9
replace  dem_position=1 if  dem_yes> dem_nay
replace  dem_position=6 if  dem_nay> dem_yes

*now generate a vote passed or failed variable, assuming we need more yes than nays for a vote to pass. remember this variable holds true only for regular votes (not applicable to nominations, etc).

gen pass_fail=.
replace pass_fail=1 if yeas>nays
replace pass_fail=0 if yeas<nays

*now we generate for each party the vote variable, categorizing each vote as a success (1), rejection (2), roll (3) or disappointment (4).

gen rep_vote=.
replace  rep_vote=1 if  rep_position==1& pass_fail==1
replace  rep_vote=2 if  rep_position==6& pass_fail==0
replace  rep_vote=3 if  rep_position==6& pass_fail==1
replace  rep_vote=4 if  rep_position==1& pass_fail==0

gen dem_vote=.
replace  dem_vote=1 if  dem_position==1& pass_fail==1
replace  dem_vote=2 if  dem_position==6& pass_fail==0
replace  dem_vote=3 if  dem_position==6& pass_fail==1
replace  dem_vote=4 if  dem_position==1& pass_fail==0

*now create a variable indicating amendments, and a variable indicating final passages of bills. in amendments i include regular amendments only; in final passages i include private and public bills.

gen amend_dummy=0
replace amend_dummy=1 if voteform==61

 gen fpv_dummy=0
replace  fpv_dummy=1 if  voteform==50
replace  fpv_dummy=1 if  voteform==51

*now save the file as the output data file, senate_45_104_output.dta. Now we can table the dem_vote and rep_vote variables by congress indicating whether the party is in govt or not, and whether we look at amendments or final passages, for instance: table  congress rep_vote if  rep_status==1& fpv_dummy==1




